Skip to content

feat(kimi): migrate to kimi-code v0.6.0 CLI#6

Merged
bbingz merged 2 commits into
mainfrom
feat/kimi-code-migration-2026-06-02
Jun 2, 2026
Merged

feat(kimi): migrate to kimi-code v0.6.0 CLI#6
bbingz merged 2 commits into
mainfrom
feat/kimi-code-migration-2026-06-02

Conversation

@bbingz
Copy link
Copy Markdown
Owner

@bbingz bbingz commented Jun 2, 2026

Branch 2 of 3. Adapts the kimi provider to kimi-code v0.6.0 (the local kimi is no longer the python kimi-cli).

Why

kimi-code's one-shot -p mode rejects --yolo/--auto/--plan and dropped --print/--input-format/--no-thinking/--max-steps-per-turn; the session store moved to ~/.kimi-code/ and the session id is now session_<uuid> emitted as a structured session.resume_hint event. The previous adapter was built for the python CLI and would error against kimi-code.

Runtime (kimi.js, full rewrite)

  • Invocation: -p <prompt> --output-format stream-json (+ -m, + -r <id> / -C). No --yolo/--print/--input-format.
  • Session id read structurally from the resume_hint event (keeps the session_ prefix; never scans prose → no fabrication).
  • Deleted the dead resume machinery (resolveKimiResumeSession/kimi.json/md5 sessions dir/validateKimiResumeTarget); resume delegated to the CLI (-C / -r <id>). Dropped the python-era resume-mismatch warning.
  • Auth probe drops --max-steps-per-turn (now config-level) + normalizes ETIMEDOUT (probe timeout stays inconclusive). Config/default-model path → ~/.kimi-code/config.toml.

Host + review

  • sessions.mjs kimi purge derivation → ~/.kimi-code/sessions/wd_<base>_<sha256(realCwd)[:12]>/<id>/ (verified on disk).
  • kimi /review is now prompt-only (like minimax): -p mode has no read-only flag, so REVIEW_HARD_CONSTRAINTS.kimi() returns {}. A drift CHECK now guards the load-bearing -p/--output-format flags — this also resolves the deep-review "kimi uncovered in drift checks" finding.
  • kimi ask path unconstrained (no -p-compatible constraint flags).

Validation

npm test 451/451; companion bundles byte-identical.

Doc-debt (follow-up)

The kimi-cli-runtime / kimi-prompting skill prose + provider-paths.md + polycli-v1-public-surface.md still describe the legacy python flags. Advisory only (not the code contract); flagged for a doc sweep.

bbingz added 2 commits June 2, 2026 12:07
…-cli contract)

The local `kimi` binary is now kimi-code v0.6.0 (~/.kimi-code), not the python kimi-cli. Its
one-shot `-p` mode rejects --yolo/--auto/--plan and dropped --print/--input-format/--no-thinking/
--max-steps-per-turn, and the session id is now `session_<uuid>` emitted structurally.

Runtime (packages/polycli-runtime/src/kimi.js, full rewrite):
- buildKimiInvocation: `-p <prompt> --output-format stream-json` (+ -m, + -r <id> / -C). No --yolo
  (rejected with -p), no --print/--input-format (removed upstream).
- session id read STRUCTURALLY from the `{role:"meta",type:"session.resume_hint",session_id}` event
  (keeps the `session_` prefix; never scans prose for a bare UUID -> no fabrication).
- deleted the dead resume machinery (resolveKimiResumeSession/readKimiLastSession/validateKimiResume
  Target/kimi.json/md5-sessions-dir) — resume is delegated to the CLI; resumeLast -> -C, resume -> -r.
  Also drops the resume-mismatch warning (a python-kimi quirk guard).
- auth probe drops --max-steps-per-turn (now config.toml-level) and normalizes ETIMEDOUT so a probe
  timeout stays inconclusive. default-model + config path -> ~/.kimi-code/config.toml.

Host + review:
- sessions.mjs kimi purge derivation -> ~/.kimi-code/sessions/wd_<base>_<sha256(realCwd)[:12]>/<id>/
  (verified on disk); storeRoot kimi -> .kimi-code/sessions.
- kimi /review is now prompt-only (like minimax): -p mode has no flag-based read-only lever, so
  REVIEW_HARD_CONSTRAINTS.kimi() returns {} and REVIEW_FLAG_EXPECTATIONS.kimi drops the stale
  --no-thinking/--max-steps tokens. A drift CHECK now guards the load-bearing -p/--output-format
  invocation flags (resolves the review-drift "kimi uncovered" finding).
- prompt-runtime ask path for kimi is unconstrained (no -p-compatible constraint flags exist).

Tests: kimi.test.js rewritten for the new contract; integration/prompt-runtime/sessions/review-flags
/consistency/exports tests updated. npm test 451/451; companion bundles byte-identical.

Doc-debt (follow-up): the kimi-cli-runtime / kimi-prompting skill prose + provider-paths.md +
polycli-v1-public-surface.md still describe the legacy python kimi-cli flags; advisory only, not
the code contract. Tracked in memory project_deep_review_2026_06_02.
…ssion parse

Addresses the pre-merge Codex review gate for PR #6.

- resume flag (real bug): buildKimiInvocation emitted `-r <id>` for
  resume-by-id, but kimi-code v0.6.0 has NO `-r` flag — `kimi --help`
  shows resume-by-id is `-S, --session [id]` (continue-last `-C` is
  correct). `-r` would be rejected at runtime, and the path IS reachable
  (`polycli rescue --provider kimi --resume <id>` threads through to it,
  per integration test). Switch to `--session <id>`; update unit +
  integration assertions and the comment.
- session-id parse (hardening): parseKimiStreamText adopted session_id
  from ANY `role:"meta"` event; the documented source is specifically the
  `{role:"meta", type:"session.resume_hint", session_id:"session_<uuid>"}`
  event. Require `type === "session.resume_hint"` so an unrelated meta
  event carrying a session_id is not promoted. Add a regression test.
- fragile review test (latent failure exposed by committing the
  migration): two `review --base HEAD~1 --scope branch` integration tests
  asserted `doesNotMatch(argv.join(" "), /--no-thinking|--max-steps.../)`.
  The reviewed diff is embedded in the single `-p <prompt>` element and
  legitimately mentions those removed flags as deleted-code text, so the
  substring check false-positives on this very migration's diff. Check the
  flags as discrete argv tokens (argv.includes) instead — same intent,
  no false positive.

Codex false-positives (verified, NOT changed): #1 `-p`+`--plan/--auto/--yolo`
combination is latent-only — no caller injects those (review extraArgTokens
empty; prompt-runtime kimi-ask is plain `-p`); #4 the `~/.kimi/` literal is
an intentional migration-history comment, code uses `~/.kimi-code/`.

npm test 452/452 (was 451; +1 session-parse regression). 5 bundles byte-identical.
@bbingz bbingz merged commit 6c970db into main Jun 2, 2026
1 check failed
@bbingz bbingz deleted the feat/kimi-code-migration-2026-06-02 branch June 2, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant